package com.canbot.u05.activity.shoppingGuide.sales;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.canbot.u05.MainApplication;
import com.canbot.u05.R;
import com.canbot.u05.activity.BaseActivityNoTitle;
import com.canbot.u05.glide.GlideApp;
import com.canbot.u05.socket.IpMsgConst;

/**
 * 图片预览
 */
public class SalesMapPreviewActivity extends BaseActivityNoTitle {

        private android.widget.ImageView ivpreviewcontent;

        private android.widget.Button btndelete;

        private android.widget.Button btncheck;

        private android.widget.RelativeLayout activitysalesmappreview;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_sales_map_preview);
                initView();
                String path = getIntent().getStringExtra("path");//图片的路径
                // TODO: 2017/3/17 图片添加
                //VolleyUtil.requestImage(ApiUtil.HTTP+path,ivpreviewcontent,R.drawable.sales_banner01,R.drawable.sales_banner01);
                GlideApp.with(this)
                        .asDrawable()
                        .load(IpMsgConst.HTTP_URL_CHEST + path)
                        .thumbnail(0.1f)
                        .diskCacheStrategy(DiskCacheStrategy.ALL)//缓存策略
                        .skipMemoryCache(false)
                        .placeholder(R.drawable.sales_banner01)//占位图
                        .error(R.drawable.ic_picture_loadfailed)
                        .override(100, 100)
                        .into(ivpreviewcontent);
        }

        private void initView() {
                this.activitysalesmappreview = (RelativeLayout) findViewById(R.id.activity_sales_map_preview);
                this.btncheck = (Button) findViewById(R.id.btn_check);
                this.btndelete = (Button) findViewById(R.id.btn_delete);
                this.ivpreviewcontent = (ImageView) findViewById(R.id.iv_preview_content);
        }

        /**
         * 取消
         *
         * @param view
         */
        public void delete(View view) {
                setResult(RESULT_CANCELED);
                finish();
                overridePendingTransition(R.anim.face_zoom_enter,
                                          R.anim.face_zoom_exit);

        }

        /**
         * 确定选中
         *
         * @param view
         */
        public void check(View view) {
                Intent intent = new Intent();
                intent.putExtra("ischeck", true);
                setResult(RESULT_OK, intent);
                finish();
                overridePendingTransition(R.anim.face_zoom_enter,
                                          R.anim.face_zoom_exit);
        }
}
